<template>
	<sl-loading loadingdata="加载中..."></sl-loading>
</template>

<script>
	import DistributionApi from '@/api/distribution/distribution.js';
	import ApplyCode from '@/utils/distribution/applyCode.js';
	//
	export default {
		//
		name: 'transition',
		//
		data() {
			return {
				//
				code: '',
			};
		},
		//
		onLoad(options) {
			//
			this.checkDistribution();
			// let abc = ApplyCode.getValueByKey('2001003')
			// this.$app.navTo(abc)
			// console.log('abc: ',abc);
			//

			//
			// console.log('options:------------------1 ', options);
			// //如果有分销人对象，跳转到流量中心首页
			// if (Object.keys(this.saler).length > 0) {
			// 	this.$app.navTo(this.pages.IndexDistributionPage);
			// 	console.log('options:------------------2 ', options);
			// } 
			// //如果没有分销人对象，且已经提交资料，跳转到申请结果页面
			// else if (false) {

			// } 
			// //如果没有分销人对象，且也没有提交资料，跳转到申请页面
			// else {
			// 	console.log('options:------------------3 ', options);
			// 	this.$app.navTo(this.pages.marketingApplyPage);
			// }
			// console.log('options:------------------4 ', options);
		},
		onShow() {},
		//
		methods: {
			checkDistribution: async function() {
				let res = await DistributionApi.apply();
				this.code = res.code;
				let url = '';
				let name = ''
				let isEnd = true;
				if (this.code == 1) {
					url = ApplyCode.getValueByKey(this.code.toString() + res.obj.audits);
					name = ApplyCode.getNameByKey(this.code.toString() + res.obj.audits);
					if (res.obj.audits == 4) {
						name = res.obj.auditRemarks;
						isEnd = true;
					}
				} else {
					url = ApplyCode.getValueByKey(this.code.toString());
					name = ApplyCode.getNameByKey(this.code.toString());
					isEnd = false;
				}
				this.$app.navTo(url, {
					name,
					isEnd
				})
			},
		}
	};
</script>

<style lang="scss" scoped>

</style>